package com.hospital.hospitalserver.entity;

import lombok.Data;

import java.time.LocalDateTime;

/**
 * 排班类型数据表
 * */
@Data
public class ScheduleTypeInfo {
    private Integer type_id; //类型ID
    private String type_code; //类型代码
    private String type_name; //类型名称
    private String description; //类型描述
    //分类: outpatient门诊, inpatient住院, pharmacy药房, finance财务, admin行政, service后勤
    private String category;
    private Integer requires_fee_item; //是否需要费用项目
    private Integer requires_patient_limit; //是否需要患者限制
    private Integer requires_pharmacy_info; //是否需要药房信息
    private Integer requires_window_info; //是否需要窗口信息
    private Integer is_active; //是否启用
    private Integer sort_order; //排序
    private LocalDateTime create_time;
    // ========== 新增字段 ==========
    private String location_type; // 地点类型: fixed-固定, department_based-基于科室, custom-自定义
    private String default_location; // 默认工作地点

    // ========== 业务方法 ==========

    /**
     * 是否需要业务信息
     */
    public boolean requiresBusinessInfo() {
        return requires_fee_item == 1 || requires_patient_limit == 1 ||
                requires_pharmacy_info == 1 || requires_window_info == 1;
    }

    /**
     * 是否为基于科室的地点类型
     */
    public boolean isDepartmentBasedLocation() {
        return "department_based".equals(location_type);
    }

    /**
     * 是否为固定地点类型
     */
    public boolean isFixedLocation() {
        return "fixed".equals(location_type);
    }

    /**
     * 生成完整的工作地点（基于科室名称）
     */
    public String generateFullLocation(String departmentName) {
        if (isDepartmentBasedLocation() && departmentName != null && !departmentName.trim().isEmpty()) {
            return departmentName + default_location;
        }
        return default_location != null ? default_location : "工作区域";
    }

    /**
     * 获取分类显示名称
     */
    public String getCategoryDisplayName() {
        switch (category) {
            case "outpatient": return "门诊";
            case "inpatient": return "住院";
            case "pharmacy": return "药房";
            case "finance": return "财务";
            case "admin": return "行政";
            case "service": return "后勤";
            default: return "通用";
        }
    }
}
